home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MPW C++ / MPW C++ 3.1 / Interfaces / CIncludes / generic.h < prev    next >
Text File  |  1990-09-11  |  2KB  |  79 lines

  1. /*ident    "@(#)ctrans:incl/generic.h    1.1.6.2" */
  2. /**************************************************************************
  3.             Copyright (c) 1984 AT&T
  4.                 All Rights Reserved      
  5.  
  6.     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  7.     
  8.     The copyright notice above does not evidence any       
  9.     actual or intended publication of such source code.
  10.  
  11. *****************************************************************************/
  12.  
  13. #ifndef __GENERIC__
  14.  
  15. #define __GENERIC__ 1
  16.  
  17. /* macros to paste tokens together to form new names */
  18. /* BSD and SystemV cpp's have different mechanisms for pasting tokens
  19.    together:  worse yet, suns run under BSD but have SYSV mechanism.
  20.    ANSI C has defined a new way.
  21. */
  22.  
  23. #ifdef applec // for Macintosh
  24. /* ANSI C preprocessors will not expand the arguments to a macro;
  25.  * so we need to add a level of indirection to allow macro expansion of
  26.  * arguments.  (Reiser preprocessors allowed the first arg to be expanded;
  27.  * this method will allow both to be expanded, which is better than none.)
  28.  */
  29. #define name2(a,b)      _name2_aux(a,b)
  30. #define _name2_aux(a,b)      a##b
  31. #define name3(a,b,c)    _name3_aux(a,b,c)
  32. #define _name3_aux(a,b,c)    a##b##c
  33. #define name4(a,b,c,d)  _name4_aux(a,b,c,d)
  34. #define _name4_aux(a,b,c,d)  a##b##c##d
  35.  
  36. #else 
  37. #ifdef sun
  38. /*System V way: although BSD is true*/
  39.  
  40. #define name2(a,b)    a/**/b
  41. #define name3(a,b,c)    a/**/b/**/c
  42. #define name4(a,b,c,d)    a/**/b/**/c/**/d
  43.  
  44. #else
  45. #ifdef  BSD
  46. /*BSD way:*/
  47.  
  48. #define name2(a,b) a\
  49. b
  50. #define name3(a,b,c) a\
  51. b\
  52. c
  53. #define name4(a,b,c,d) a\
  54. b\
  55. c\
  56. d
  57.  
  58. #else
  59. /*System V way:*/
  60. #define name2(a,b)    a/**/b
  61. #define name3(a,b,c)    a/**/b/**/c
  62. #define name4(a,b,c,d)    a/**/b/**/c/**/d
  63. #endif
  64. #endif
  65. #endif
  66.  
  67. #define declare(a,t) name2(a,declare)(t)
  68. #define implement(a,t) name2(a,implement)(t)
  69. #define declare2(a,t1,t2) name2(a,declare2)(t1,t2)
  70. #define implement2(a,t1,t2) name2(a,implement2)(t1,t2)
  71.  
  72.  
  73. extern genericerror(int,char*);
  74. typedef int (*GPT)(int,char*);
  75. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  76. #define errorhandler(generic,type) name3(type,generic,handler)
  77. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  78. #endif
  79.